import pandas as pd

df = pd.read_csv('tips.csv')

# 处理输入
input_data = list(map(str, input().split()))
if len(input_data) != 5:
    raise ValueError("输入参数数量不正确，需要5个参数。")

gender, smoker, day, time_period, total_bill = input_data

# 转换数据类型
gender = int(gender)
smoker = int(smoker)
day = int(day)
time_period = int(time_period)
total_bill = float(total_bill)

# 检查输入值的范围
if gender not in [0, 1]:
    raise ValueError("性别必须是0(女性)或1(男性)")
if smoker not in [0, 1]:
    raise ValueError("是否吸烟必须是0(否)或1(是)")
if day < 0 or day > 6:
    raise ValueError("星期几必须是0(周日)到6(周六)之间的整数")
if time_period not in [0, 1]:
    raise ValueError("用餐时间段必须是0(午餐)或1(晚餐)")
if total_bill < 0:
    raise ValueError("消费金额不能为负数")

# 映射星期几
day_mapping = {0: 'Sun', 1: 'Mon', 2: 'Tue', 3: 'Wed', 4: 'Thu', 5: 'Fri', 6: 'Sat'}
time_mapping = {0: 'Lunch', 1: 'Dinner'}
gender_mapping = {0: 'Female', 1: 'Male'}
smoker_mapping = {0: 'No', 1: 'Yes'}

# 筛选数据
filtered_df = df[
    (df['sex'] == gender_mapping[gender]) &
    (df['smoker'] == smoker_mapping[smoker]) &
    (df['day'] == day_mapping[day]) &
    (df['time'] == time_mapping[time_period])
]

# 计算小费比例的平均值
if len(filtered_df) > 0:
    filtered_df['tip_percentage'] = (filtered_df['tip'] / filtered_df['total_bill']) * 100
    avg_tip_percentage = filtered_df['tip_percentage'].mean()
else:
    # 如果没有匹配的数据，使用整体平均值或默认值
    df['tip_percentage'] = (df['tip'] / df['total_bill']) * 100
    avg_tip_percentage = df['tip_percentage'].mean()

# 计算预测的小费
predicted_tip = (avg_tip_percentage / 100) * total_bill

# 输出结果，保留两位小数
print(f"{predicted_tip:.2f}")